﻿using System;
using Cuce.ReportingServices.SSRSWS;
using NUnit.Framework;

namespace Cuce.ReportingServices.UnitTests
{
    /// <summary>
    /// ReportingServiceHelper Unit Test
    /// </summary>
    [TestFixture]
    public class ReportingServiceHelperDownloadTest
    {
        private readonly IReportingService i = new Mock.ReportingServicesMock();


        /// <summary>
        /// Somes the test.
        /// </summary>
        [Test]
        public void ReportingServiceHelperWorkingTest()
        {

            var name = new ReportName("test", "/CRR/");

            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(i, name));
        }

        /// <summary>
        /// Reportings the service helper name null.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServiceHelperNameNull()
        {

            Assert.IsTrue("" == ReportingServiceHelper.DownloadReport(i, null));
        }

        /// <summary>
        /// Reportings the service helper no folder.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServiceHelperNoFolder()
        {

            var name = new ReportName("test", "");
            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(i, name));


        }

        /// <summary>
        /// Reportings the name of the service helper no report.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServiceHelperNoReportName()
        {

            var name = new ReportName("", "/CRR/");
            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(i, name));

        }



        /// <summary>
        /// Reportings the service helper no RS.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServiceHelperNoRS()
        {

            var name = new ReportName("dfgd", "/CRR/");
            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(null, name));


        }

        /// <summary>
        /// Reportings the service helper major error.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ReportException))]
        public void ReportingServiceHelperMajorError()
        {
            var name = new ReportName("error", "/CRR/");
            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(i, name));


        }

        /// <summary>
        /// Reportings the service helper major warning.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ReportException))]
        public void ReportingServiceHelperMajorWarning()
        {

            var name = new ReportName("warning", "/CRR/");
            Assert.IsTrue(name.ToString() == ReportingServiceHelper.DownloadReport(i, name));


        }

    }
}
